<template>
    <div>
        <h1>Action</h1>
        <h1>{{num}}</h1>
        <button @click="addNum">增加数量+1</button>
        <button @click="getDuanzi">获取段子</button>
        <button @click="setDz">获取段子</button>
        <ul>
            <li v-for="(item,index) in duanzi" :key="index">{{index+1}}:{{item.text}}</li>
        </ul>
    </div>
</template>

<script>
// 导入
import {mapState,mapMutations,mapActions,mapGetters} from "vuex";
let mapStateObj = mapState(["duanzi","num"]);
let mapMutationsObj = mapMutations(["addNum","setNum"]);
let mapActionsObj = mapActions(["setDz"]);
let mapGettersObj = mapGetters(["reverseMsg"]);
export default {
    computed:{
        ...mapStateObj,
        ...mapGettersObj
    },
    methods:{
        getDuanzi(){
            this.$store.dispatch("setDz");
            console.log(this);
            
        },
        ...mapMutationsObj,
        ...mapActionsObj
    }
}
</script>

<style>

</style>